package com.chat.service.impl;

import com.chat.service.ChatService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import dev.langchain4j.model.chat.ChatLanguageModel;

@RequiredArgsConstructor
@Service
public class ChatServiceImpl implements ChatService {

    private final ChatLanguageModel chatModel;

    @Override
    public String chat(String message) {
        try {
            return chatModel.generate(message);
        } catch (Exception e) {
            return "AI服务暂时不可用：" + e.getMessage();
        }
    }
}
